//
//  VideoDetailTableCell.m
//  滴滴快拍
//
//  Created by dllo on 16/5/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "VideoDetailTableCell.h"

@implementation VideoDetailTableCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}


- (void)setComment:(AGLComment *)comment {
    if (_comment != comment) {
        _comment = comment;
    }
    [self createData];
}

- (void)createView {
    self.fromIconImage = [[BaseImageView alloc] init];
    [self.contentView addSubview:self.fromIconImage];
    
    self.fromNickLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:self.fromNickLabel];
    
    self.commentLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:self.commentLabel];
    
    self.createTimeNiceLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:self.createTimeNiceLabel];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.fromIconImage.frame = CGRectMake(20, 10, SCREEN_WIDTH/6, SCREEN_WIDTH/6);
    self.fromIconImage.layer.cornerRadius = SCREEN_WIDTH /12;
    self.fromIconImage.layer.masksToBounds = YES;
    self.fromNickLabel.frame = CGRectMake(20 + self.fromIconImage.frame.size.width + 10, 10, SCREEN_WIDTH/4*3, SCREEN_WIDTH/12);
    self.fromNickLabel.textColor = [UIColor grayColor];
    self.commentLabel.frame = CGRectMake(20 + self.fromIconImage.frame.size.width + 10, 20 + SCREEN_WIDTH/12, SCREEN_WIDTH-10-(20 + self.fromIconImage.frame.size.width + 10), SCREEN_WIDTH/12);
    self.commentLabel.font = [UIFont systemFontOfSize:15];
    self.commentLabel.numberOfLines = 0;
    [self.commentLabel sizeToFit];
    
    self.createTimeNiceLabel.frame = CGRectMake(SCREEN_WIDTH /4 *3, 10, SCREEN_WIDTH/4, SCREEN_WIDTH /12);
    self.createTimeNiceLabel.textColor = [UIColor grayColor];
    self.createTimeNiceLabel.font = [UIFont systemFontOfSize:12];
    
    
}

- (void)createData {
    [self.fromIconImage setImageWithURL:[NSURL URLWithString:self.comment.fromIcon] placeholderImage:[UIImage imageNamed:@"PlaceHolder"]];
    self.fromNickLabel.text = self.comment.fromNick;
    self.commentLabel.text = self.comment.content;
    self.createTimeNiceLabel.text = self.comment.createTimeNice;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
